package com.hawk.eye.client.toolkit;

import com.hawk.eye.common.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;

/**
 * @className: HawkEyeLogger
 * @description:
 * @author: salad
 * @date: 2024/10/5
 **/
public class HawkEyeLogger {

    public static final Marker IS_SKIP_SEND_MARKER = MarkerFactory.getMarker("isSkipSend");

    public static void error(Class<?> clazz, String message, boolean isSkipSend, Throwable throwable, Object... args) {
        Logger log = LoggerFactory.getLogger(clazz);
        if (isSkipSend) {
            if (throwable != null) {
                log.error(IS_SKIP_SEND_MARKER, StringUtil.format(message, args), throwable);
            } else {
                log.error(IS_SKIP_SEND_MARKER, StringUtil.format(message, args));
            }
        } else {
            if (throwable != null) {
                log.error(StringUtil.format(message, args), throwable);
            } else {
                log.error(StringUtil.format(message, args));
            }
        }
    }

    public static void error(Class<?> clazz, String message, boolean isSkipSend, Object... args) {
        error(clazz, message, isSkipSend, null, args);
    }

    public static void errorWithSkipSend(Class<?> clazz, String message, Object... args) {
        error(clazz, message, true, null, args);
    }

    public static void errorWithSkipSend(Class<?> clazz, String message, Throwable throwable, Object... args) {
        error(clazz, message, true, throwable, args);
    }

}
